package com.morphiastic;

import java.util.Iterator;

import com.google.code.morphia.query.Query;

public class DefaultBulkDeleteFromIndexWorker implements IndexWorker{

	
	private IndexedClass indexedClass;
	private Query<?> query;
	private ElasticStore elasticStore;
	
	
	public DefaultBulkDeleteFromIndexWorker(IndexedClass indexedClass,
			Query<?> query, ElasticStore elasticStore) {
		this.indexedClass = indexedClass;
		this.query = query;
		this.elasticStore = elasticStore;
	}


	@Override
	public void run() {
		Iterator<?> iterator = query.iterator();
		while (iterator.hasNext()) {
			Object object =  iterator.next();
			elasticStore.deleteFromIndex(indexedClass,object);
		}
	}

	
	
	
}
